home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_sea_leverpump.cog < prev    next >
Text File  |  1999-11-15  |  16KB  |  601 lines

  1. # Jones 3D Cog Script
  2. #
  3. # sea_leverpump.cog
  4. #
  5. # [DS & revised by HB]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ==============================================================================
  10.  
  11. symbols
  12.  
  13.     message        startup
  14.     message        activated
  15.     message        entered
  16.     message        timer
  17.     message        touched
  18.     message        taken
  19.     message        user0
  20.     message        pulse
  21.  
  22.     keyframe    in_pull=in_pull_lever.key                    local
  23.     keyframe    in_push=in_push_lever.key                    local
  24.     keyframe    lever_pull=gen_lever_pull.key                    local
  25.     keyframe    lever_push=gen_lever_push.key                    local
  26.     keyframe    pumpactive=sea_pump_machine.key                local
  27.     keyframe    grdstart=01h_sailor_stucklever_a.key            local
  28.     keyframe    guardpump=01h_sailor_stucklever_b.key            local
  29.     keyframe    grdstop=01h_sailor_stucklever_c.key                local
  30.     sound        in_sayline=Inxj060.wav                        local # not right answer
  31.     sound        in_notgoodidea=Inxj061.wav                    local
  32.     sound        in_nope=Inxj088.wav                        local
  33.     sound        in_take2=Inxj198.wav                        local
  34.     thing        player                                local
  35.     thing        indyactor
  36.     thing        campos
  37.     thing        pump
  38.     thing        leverpos
  39.     thing        lever0                                    local
  40.     thing        lever1                                    local
  41.  
  42.     cog            hintcog                                    # sea_hints.cog
  43.     cog            sight_cog
  44.  
  45.     template    pullever0=pullever                        local
  46.     template    pushlever0=pushlever                    local
  47.  
  48.     int            curcam                                    local
  49.     int            running=0                                local
  50.     int            stuckpump                                local
  51.     int            grdstartit                                local
  52.     int            grdstopit                                local
  53.     int            touched=0                                local
  54.     int            solved=0                                local
  55.     int            newline=50                                local # init out of range
  56.     int            oldline=50                                local # init out of range
  57.  
  58.     sound        pumpon=sea_pump_on_c.wav                local
  59.     sound        pumpstart=sea_pump_start_c.wav            local
  60.     sound        pumpstop=sea_pump_stop_c.wav                local
  61.     sound        leverpull=nub_lever_pull_c.wav            local
  62.     sound        bop_indy=sea_bop_indy.wav                local
  63.     
  64. #---------lighting effects-----------------------
  65.     thing        lightpos
  66.     sector    pumprum0
  67.     sector    pumprum1
  68.     sector    pumprum2
  69.     sector    pumprum3
  70.     sector    pumprum4
  71.     vector    vecMinLight                            local
  72.     vector    vecWhtLight                            local
  73.     vector    vecMaxRedLt                            local
  74.     vector    vecrumdark                            local
  75.     vector    vecrumlight                            local
  76.     float        period=2.0                            local    
  77.     float        maxRedLightR=1.0                        local    
  78.     float        maxRedLightG=0.0                        local
  79.     float        maxRedLightB=0.0                        local
  80.     float        minLightR=0.0                            local
  81.     float        minLightG=0.0                            local
  82.     float        minLightB=0.0                            local
  83.     float        minRadius=0.0                            local
  84.     float        maxRadius=0.4                            local
  85.     float        ltR=0.4                                    local    
  86.     float        ltG=0.4                                    local
  87.     float        ltB=0.4                                    local
  88.     float        drkR=0.15                                local    
  89.     float        drkG=0.15                                local
  90.     float        drkB=0.2                                local
  91.  
  92.     int            cnt                                        local
  93.     int            lightnum                                local
  94.     int            pumpit                                    local
  95.     int            pumpgo                                    local
  96.     int            startsnd                                local
  97.     int            lv_track                                local
  98.  
  99. #---------Guard alert ----------------------------
  100.  
  101.     sound        guardsnd0=se01q07.wav                    local        #What?
  102.     sound        guardsnd1=inxh1003.wav                    local        #Give up Jones!
  103.     sound        mp_talk=Inxj198.wav                    local
  104.  
  105.     thing        guardpos
  106.     thing        movepos0
  107.     thing        movepos1
  108.     thing        mac2pos
  109.     thing        mp2                                        local
  110.     thing        guard0                                    local
  111.  
  112.     surface        guardsurf
  113.  
  114.     sector        hall0
  115.  
  116.     template    sailor=sailor_tokarev                    local
  117.     template    macpart2=imp2                            local
  118.  
  119. #---------Put indy back in cell-------------------
  120.  
  121.     keyframe    acthit=01h_sailor_pistolwhip.key        local
  122.     keyframe    in_raiseHands=0in_stand1_bd_3.key        local
  123.     keyframe    in_fall=in_die_buckle.key                local
  124.  
  125.     thing        caughtindy                                local # create on the fly
  126.  
  127.     cog            brigcog                                    # sea_BrigDoor.cog
  128.     cog            weaponcog                                # sea_WeaponControl.cog
  129.     cog            doorcog_imp2                            # sea_DoorRotate_L.cog
  130.     cog            doorcog_pump                            # sea_DoorRotate_R.cog
  131.  
  132.     sector        hold1
  133.     sector        targetsector                            local # create on the fly
  134.  
  135.     template    indy_tpl=indy_actor                        local
  136.  
  137.     vector        v_targetpos                                local
  138.     
  139.     int            solved=0                                local
  140.     int            inhall=0                                local
  141.     int            bypump=0                                local
  142.     int            alerted=0                                local
  143.     int            indyturning=0                            local
  144.     int            in_track1                                local
  145.     int            in_colltype                                local
  146.     int            curhealth                                local
  147.     int            guard_at_pump=0                            local            
  148.  
  149. #--------- Kill Indy ----------------------------
  150.  
  151.     sound        guardsnd3=se01q05.wav                    local        # Enough!
  152.     sound        killsnd=gen_pistol_fire.wav                local
  153.  
  154.     int            notagain=0                                local
  155.     int            victim                                    local
  156.  
  157. # ---------Camera Fade Stuff----------------------------------------------
  158.  
  159.     thing        fadeghost
  160.     thing        fadething
  161.  
  162. # -------------- subroutine ------------------------------
  163.     flex        indy_caught                    local
  164.  
  165. end
  166.  
  167. # ==============================================================================
  168.  
  169. code
  170.  
  171. # ..............................................................................
  172.  
  173. startup:
  174.  
  175.     player = GetLocalPlayerThing();
  176.     lever0 = CreateThing(pullever0, leverpos);
  177.     capturething(lever0);
  178.     vecMinLight = VectorSet(minLightR, minLightG, minLightB);
  179.     vecRumDark = VectorSet(drkR, drkG, drkB);
  180.     vecMaxRedLt = VectorSet(maxRedLightR, maxRedLightG, maxRedLightB);
  181.     vecRumLight = VectorSet(ltR, ltG, ltB);
  182.     mp2=CreateThing(macpart2, mac2pos);
  183.     CaptureThing(mp2);
  184.     guard0 = CreateThing(sailor, guardpos);
  185.     CaptureThing(guard0);
  186.     SetActorFlags(guard0, 0x8); # Invul.
  187.     AISetCutsceneMode(guard0);
  188.     SetThingAlpha(guard0, 1.0);
  189.     return;
  190.  
  191. # ..............................................................................
  192.  
  193. activated:
  194.  
  195.     if ((GetSenderRef() == lever0) || (GetSenderRef() == lever1))
  196.     {
  197.         if(solved != 0)
  198.         {    
  199.             MakeMeStop();
  200.             StartCutScene(1);
  201.             SetExtCamOffsetToThing(campos);
  202.             while(newline == oldline)
  203.             {
  204.                 newline = RandBetween(0, 2);
  205.             }
  206.             oldline = newline;
  207.             PlayVoice(indyactor, in_sayline[newline], 1.0, 1);
  208.             RestoreExtCam();
  209.             EndCutscene();
  210.             ClearActorFlags(player, 0x200000);
  211.             return; # now bail out...
  212.         }
  213.         if(running != 0) return;
  214.  
  215.         running = 1;
  216.         curcam = GetCurrentCamera();
  217.         SetThingFlags(player, 0x80000);
  218.         SetActorFlags(player, 0x200000); # no control
  219.         CopyPlayerHolsters(player, indyactor);
  220.         StartCutscene(1);
  221.         SetCameraPosInterp(2, 0); # snap to new pos
  222.         ClearThingFlags(indyactor, 0x80000);
  223.         SetCameraFocus(2, campos);
  224.         SetCameraSecondaryFocus(2, indyactor);
  225.         SetCurrentCamera(2);
  226.         SetCameraFOV(90, 0, 0.0); # already there
  227.  
  228.         SendMessageEx(hintcog, user0, 1, 0, 0, 0); # param0=1; pump on
  229.         
  230.         lv_track = PlayKey(lever0, lever_pull, 4, 0x12, 0);
  231.         PlayKey(indyactor, in_pull, 4, 0x12, 0);
  232.         Sleep(1.2);
  233.         PlaySoundLocal(leverpull, 1.0, 0, 0x0, 0);
  234.         Sleep(1.3);    
  235.         StopKey(lever0, lv_track, 0.0);
  236.         DestroyThing(lever0);
  237.         lever1 = CreateThing(pushlever0, leverpos);
  238.         capturething(lever1);
  239.  
  240.         for (cnt = 0; cnt <= 4; cnt = cnt+1) 
  241.         {
  242.             SetSectorLight(pumprum0[cnt], vecRumDark, 0.4);
  243.         }
  244.         lightnum =
  245.             ThingLightAnim(lightpos, vecMinLight, minRadius, vecMaxRedLt, maxRadius, period);
  246.         pumpit = PlayKey(pump, pumpactive, 4, 0x10, 0);
  247.         startsnd = PlaySoundThing(pumpstart, pump, 1.0, 2.5, 10, 0);
  248.         TeleportThing(player, indyactor);
  249.         SetCurrentCamera(curcam);
  250.         ResetCameraFOV(0, 0.0);
  251.         SetThingFlags(indyactor, 0x80000);
  252.         ClearThingFlags(player, 0x80000);
  253.         EndCutscene();
  254.         ClearActorFlags(player, 0x200000);
  255.         
  256.         # TO DO:  Shouldn't timer be related to difficulty?
  257.         # No.
  258.         SetTimer(4.5); # player has 5 sec to skedaddle
  259.  
  260.         pumpgo = PlaySoundThing(pumpon, pump, 1.0, 2.5, 10, 1);
  261.     }
  262.  
  263.     return;
  264.  
  265. # ..............................................................................
  266.  
  267. entered:
  268.  
  269.     if (getSenderRef() == guardsurf)
  270.     {
  271.         SendMessage(doorcog_imp2, user5); # hold imp2 room door open
  272.         setpulse(0.0);
  273.  
  274.         if ((solved == 1) || (inhall == 1))
  275.         {
  276.             return;
  277.         }
  278.  
  279.     # Indy has foolishly stumbled into pump guard's presence...
  280.         alerted = 1; # for timer 
  281.         MakeMeStop();
  282.         goto indy_caught;
  283.         return;
  284.     }
  285.     if((GetSenderRef() == Pumprum0) && (guard_at_pump == 1))
  286.     {
  287.         inhall=0;                # player may have entered from hall, reset.
  288.  
  289.         if (IsInvisible() == 1)     # 1=indy invisible, 0=visible
  290.         {
  291.             setPulse(0.5);
  292.             return;
  293.         }
  294.  
  295.         solved=0;                # player will loose imp part.
  296.  
  297.     # Indy has foolishly stumbled into pump guard's presence...
  298.         alerted = 1; # for timer 
  299.         MakeMeStop();
  300.         Stopkey(guard0, stuckpump, 0.5);
  301.         Sleep(0.5);
  302.         goto indy_caught;
  303.         return;
  304.     }
  305.     if (GetSenderRef() == pumprum0)
  306.     {
  307.         inhall = 0;
  308.         SendMessage(doorcog_pump, user5); # keep door open
  309.         return;
  310.     }
  311.     if(getSenderRef() == hold1)
  312.     {
  313.         inhall = 0;
  314.         if(running != 1) return;
  315.         running = 0;
  316.         DestroyThing(guard0);
  317.         StopKey(pump, pumpit, 1.0);
  318.         Stopsound(pumpgo, 1.0);
  319.         DestroyThing(lever1);
  320.         lever0 = CreateThing(pullever0, leverpos);
  321.         capturething(lever0);
  322.         StopAnim(lightnum);
  323.         for (cnt = 0; cnt <= 4; cnt = cnt+1) 
  324.         {
  325.             SetSectorLight(pumprum0[cnt], vecRumLight, 0.4);
  326.         }
  327.         guard_at_pump=0;
  328.         guard0 = CreateThing(sailor, guardpos);
  329.         CaptureThing(guard0);
  330.         SetThingAlpha(guard0, 1.0);
  331.         if (solved == 1)
  332.         {
  333.             return;
  334.         }
  335.         SetActorFlags(guard0, 0x8); # Invul.
  336.         AISetCutsceneMode(guard0);
  337.         return;
  338.     }
  339.  
  340.     if (GetSenderRef() == hall0)
  341.     {
  342.         setpulse(0.0);
  343.         SendMessage(doorcog_imp2, user6); # close imp2 room door
  344.         SendMessage(doorcog_pump, user6); # close pump room door
  345.         if (running == 1)
  346.         {
  347.             inhall = 1;
  348.             return;    
  349.         }
  350.         return;
  351.     }
  352.     return;
  353.  
  354. # ..............................................................................
  355.  
  356. timer:
  357.  
  358.     if (running == 0)
  359.     {
  360.         return;
  361.     }
  362.     if ((alerted == 1) || (running == 0) || (touched ==1))
  363.     {
  364.         return;
  365.     }
  366.         PlayVoice(guard0, guardsnd0, 0.6, 1);
  367.         AISetLookThing(guard0, movepos0);
  368.         AISetMoveThing(guard0, movepos0, 1);
  369.     if ((alerted == 1) || (running == 0) || (touched ==1))
  370.     {
  371.         return;
  372.     }
  373.         AISetLookThing(guard0, movepos1);
  374.         AISetMoveThing(guard0, movepos1, 1);
  375.         if (inhall != 1)
  376.         {
  377.         MakeMeStop();
  378.         goto indy_caught;
  379.         return;
  380.         }
  381.     if ((alerted == 1) || (running == 0) || (touched ==1))
  382.     {
  383.         return;
  384.     }
  385.         AISetLookThing(guard0, indyactor);
  386.         AISetMoveThing(guard0, indyactor, 1);
  387.     if ((alerted == 1) || (running == 0) || (touched ==1))
  388.     {
  389.         return;
  390.     }
  391.         AISetLookThing(guard0, pump);
  392.         SetThingMass(guard0, 0);
  393.         grdstartit=PlayKey(guard0, grdstart, 4, 0x12, 1);
  394.         stuckpump=PlayKey(guard0, guardpump, 4, 0x10, 0);
  395.         guard_at_pump=1;
  396.  
  397.     return;
  398.  
  399. # ..............................................................................
  400.  
  401. taken:
  402.  
  403.     if (GetSenderRef() == mp2)
  404.     {
  405.         SendMessage(sight_cog, user0);
  406.         SendMessageEx(hintcog, user0, 1, 1, 0, 0); # param1=1; imp#2 picked up
  407.         solved = 1;
  408.  
  409.         sleep(1.0);
  410.         PlayVoice(player, mp_talk, 1.0, 0);
  411.     }
  412.  
  413.     return;
  414.  
  415. # ..............................................................................
  416.  
  417. user0:
  418.  
  419.     notagain = 1;
  420.  
  421.     if (solved == 1)
  422.     {
  423.         # --------- Retake MP2 --------------    
  424.         solved = 0;
  425.         ChangeInv(player, 15, -1);
  426.         mp2=CreateThing(macpart2, mac2pos);
  427.         CaptureThing(mp2);
  428.  
  429.         # --------- Reset Sailor ------------    
  430.         DestroyThing(guard0);
  431.         guard0 = CreateThing(sailor, guardpos);
  432.         CaptureThing(guard0);
  433.         SetActorFlags(guard0, 0x8); # Invul.
  434.         AISetCutsceneMode(guard0);
  435.         SetThingAlpha(guard0, 1.0);
  436.     }
  437.  
  438.     return;
  439.  
  440. # ..............................................................................
  441. # Put Indy back in cell 
  442. # ..............................................................................
  443.  
  444. touched:
  445.  
  446.     if((getSenderRef() == guard0) && (getsourceref() == player))
  447.     {
  448.         if ((solved == 1) || (touched == 1))
  449.         {
  450.             return;
  451.         }
  452.  
  453.         touched = 1;
  454.  
  455.         # Indy surrenders...
  456.         StopThing(guard0);
  457. #        StartCutscene(1);
  458.         MakeMeStop();
  459.         AISetLookThing(guard0, player);    
  460.         PlayVoice(guard0, guardsnd1, 1.0, 1);
  461.  
  462.         if((running == 1) && (guard_at_pump == 1))
  463.         {
  464.         print("stop guard");
  465.             Stopkey(guard0, stuckpump, 0.5);
  466.             Sleep(0.5);
  467.         }
  468.  
  469.         If (indyturning == 0);
  470.         {
  471.             # Adjust Indy's facing...
  472.             AISetLookThing(caughtindy, guard0);
  473.             Sleep(0.5);
  474.             indyturning = 0; # reset
  475.         }
  476.         
  477.         in_track1 = PlayKey(caughtindy, in_raisehands, 4, 0x14, 0);        
  478.         Sleep(0.8);
  479.         PlayKey(guard0, acthit, 4, 0x12, 0);
  480.         Sleep(0.5);
  481.         Stopkey(caughtindy, in_track1, 0.0);
  482.         in_track1 = PlayKey(caughtindy, in_fall, 4, 0x14, 0);
  483.         PlaySoundLocal(bop_indy, 1.0, 0, 0x0, 0);
  484.  
  485.         # Record some damage (yes, player can die this way)...
  486.         curhealth = GetThingHealth(player);
  487.         SetThingHealth(player, (curhealth - 40));
  488.         Sleep(1.0);
  489.  
  490.         #-------- add fadeout here ------------------------
  491.         ClearThingFlags(fadething, 0x80000);
  492.         SetThingAlpha(fadething, 0.0); # transparent
  493.         SetCameraFadeThing(2, fadething, fadeGhost, 0);
  494.         SetCurrentCamera(2);
  495.         ThingFadeAnim(fadething, 0.0, 1.0, 1.0, 0);
  496.         ThingFadeAnim(guard0, 1.0, 0.0, 1.0, 0);
  497.         ThingFadeAnim(caughtindy, 1.0, 0.0, 1.0, 0);
  498.         Sleep(1.0);
  499.         StopKey(caughtindy, in_track1, 0.0);
  500.         SetThingAlpha(caughtindy, 1.0); # affects model
  501.         DestroyThing(caughtindy);
  502.         ClearThingFlags(player, 0x10); # visible when next we see him
  503. #        SendMessage(doorcog_imp2, user6); # close imp2 room door
  504.  
  505.         if (notagain == 1) # caught before, now kill player
  506.         {
  507.             PlayVoice(guard0, guardsnd3, 1.0, 1);
  508.             PlaySoundLocal(killsnd, 1.0, 0.0, 0x0, 0);
  509.             EndCutscene();
  510.             ClearActorFlags(player, 0x8);
  511.             DamageThing(player, 1000.0, 0x1, victim);
  512.             return;
  513.         }
  514.         notagain = 1; # next time it's death
  515.         SendMessage(brigcog, user0); # put Indy back in his cell
  516.         SendMessage(weaponcog, user0); # inform sea_weapons cog Indy's been caught once
  517.         SendMessageEx(hintcog, user0, 2, 0, 0, 0);    #param0=2; pump off back in cell
  518.  
  519.         if(GetInv(player, 15) >= 1)    
  520.             {
  521.         #    print("taking Machine Part");
  522.             ChangeInv(player, 15, -1);
  523.             mp2 = CreateThing(macpart2, mac2pos);
  524.             CaptureThing(mp2);
  525.             }
  526.  
  527.  
  528.         #----- Clean Up -------
  529.         guard_at_pump=0;
  530.         DestroyThing(guard0);
  531.         guard0 = CreateThing(sailor, guardpos);
  532.         CaptureThing(guard0);
  533.         SetActorFlags(guard0, 0x8); # Invul.
  534.         AISetCutsceneMode(guard0);
  535.         SetThingAlpha(guard0, 1.0);
  536.         touched = 0;
  537.         if (running == 1)
  538.         {
  539.             running = 0;
  540.             DestroyThing(lever1);
  541.             lever0 = CreateThing(pullever0, leverpos);
  542.             capturething(lever0);
  543.             StopAnim(lightnum);
  544.             for (cnt = 0; cnt <= 4; cnt = cnt+1) 
  545.             {
  546.                 SetSectorLight(pumprum0[cnt], vecRumLight, 0.4);
  547.             }
  548.             StopKey(pump, pumpit, 1.0);
  549.             Stopsound(pumpgo, 1.0);
  550.         }
  551.         sleep(0.5);
  552.         SendMessage(doorcog_imp2, user6); # close imp2 room door
  553.         SendMessage(doorcog_pump, user6); # close pump room door
  554.         return;
  555.     }
  556.     return;
  557.  
  558. pulse:
  559.     if (IsInvisible() == 1) # 1=indy invisible, 0=visible
  560.     {
  561.         return;
  562.     }
  563.     setpulse(0.0);
  564.  
  565.     # Indy has foolishly stumbled into pump guard's presence...
  566.         alerted = 1;                             # for timer 
  567.         solved=0;                                # player will loose imp part.
  568.         MakeMeStop();
  569.         DeselectWeaponWait(player);
  570.         PlayVoice(guard0, guardsnd0, 1.0, 1);
  571.         Stopkey(guard0, stuckpump, 0.5);
  572.         Sleep(0.5);
  573.         goto indy_caught;
  574.  
  575.     return;
  576.  
  577.  
  578. #-----------------------------------------------------------
  579. #        Subroutines
  580. #-----------------------------------------------------------
  581. indy_caught:
  582.         StartCutscene(1);
  583.         DeselectWeaponWait(player);
  584.         caughtindy = CreateThing(indy_tpl, player);
  585.         CaptureThing(caughtindy);
  586.         ClearThingFlags(caughtindy, 0x80000);
  587.         CopyPlayerHolsters(player, caughtindy);
  588.         in_colltype = GetCollideType(caughtindy);
  589.         SetCollideType(caughtindy, 0); # guard no touch actor
  590.         SetThingFlags(player, 0x10); # invisible but touchable!
  591.         AISetLookThing(guard0, caughtindy);
  592.         AISetLookThing(caughtindy, guard0);
  593.         indyturning = 1; # Indy is turning toward the guard
  594.         AISetMoveThing(guard0, player, 1);
  595.         alerted = 0;
  596.         # NOTE: Indy is caught and sent back to brig by touched code block...
  597.         return;
  598.  
  599. end
  600.  
  601.